export default class Template {
    constructor() {
        this.params = {}
        this.template = ''
    }

    setParams(params) {
        this.params = { ...params, ...this.params }
        return this
    }

    render(template, isUse = true) {
        if(!isUse) return ''
        if(!template) return console.error('template is required')
            
        this.template = template
        for (let key in this.params) {
            const value = this.params[key]
            this.template = this.template.replaceAll(`#{${key}}`, value)
        }
        return this.template
    }
}